<template>

<table class="table table-bordered">

<thead>
    <tr>

<th>房号id</th>
<th>房号</th>
<th>房号排序</th>
<th>备注</th>
<th>状态</th>
<th>操作</th>
</tr>

</thead>
<tbody v-for="item in show1">

    <tr>

<th>{{ item.hid}}</th>
<th>{{ item.hname }}</th>
<th>{{ item. paiXu}}</th>
<th>{{ item.beiZhu }}</th>
<th>{{ item.state }}</th>
<th><button @click="IsDel(item.hid)">删除</button>
    <button v-show="item.state==true" @click="updata(item.hid)"> 下架</button>
    <button v-show="item.state==false"  @click="updata(item.hid)">上架</button>

</th>
</tr>

</tbody>


</table>


</template>



<script setup lang="ts">

const  IsDel=(id:number)=>{

if(!confirm('确定删除吗'))
{
    return ;
}


    axios.delete('https://localhost:7099/api/FangHao/IsDelFangH',{params:{
        id:id,

    }}).then(res=>{

        if(res.data>0)
    {
        alert('删除成功')
    }
    else
    {
        alert('删除失败')
    }
    })
}

import axios from 'axios';
import { onMounted,ref } from 'vue';


const show1= ref([{

"hid": 1,
    "hname": "123",
    "paiXu": 0,
    "beiZhu": "string",
    "state": true,
    "isDel": true

}])

 onMounted(()=>{

    show();
 })


const show=()=>{


axios.get('https://localhost:7099/api/FangHao/ShowFanghao').then(res=>{

    show1.value=res.data;

})

}




const updata=(id:number)=>{

alert(id);
    if(!confirm('确定修改吗'))
{
    return ;
}
    axios.get('https://localhost:7099/api/FangHao/UpState',{params:{

        id:id,
    }}).then(res=>{

        if(res.data>0)
    {
        alert('修改成功')
        show();
    }
    else
    {
        alert('修改失败')
    }
    })

}



</script>